acc83b9bb98781abe50c552a4c37063d60cc4676,opennms-webapp/src/main/java/org/opennms/web/controller/admin/thresholds/ThresholdController.java,ThresholdController,gotoNewExpression,#String#,168
Before Change
ThresholdingConfigFactory configFactory=ThresholdingConfigFactory.getInstance();
Group group=configFactory.getGroup(groupName);
Expression expression=new Expression();
//Set the two default values which need to be set for the UI to work properly
expression.setDsType("node");
expression.setType("high");
//We're assuming that adding a expression puts it at the end of the current list (i.e. that the Group implementation
// uses a simple List structure, probably ArrayList). We can be a bit cleverer later on and check though, so we should
int expressionIndex=group.getExpressionCount();
group.addExpression(expression);
//Double check the guess index, just in case:
if(expression!=group.getExpression(expressionIndex)) {
After Change
//Check if last expression has expression def. If not, we assume that is a new definition (not saved yet on thresholds.xml)
Expression expression = null;
if (expressionIndex > 0) {
expression = group.getExpression(expressionIndex-1);
if (expression.getExpression() == null || expression.getExpression().equals("")) {
expressionIndex--;
} else {
expression = null;
}
}
// create a new expression object
if (expression == null) {
expression=new Expression();
//Set the two default values which need to be set for the UI to work properly
expression.setDsType("node");
expression.setType("high");
expression.setTrigger(1); //Default to 1 - 0 will give an error, so we may as well be helpful
group.addExpression(expression);
}
//Double check the guess index, just in case: